﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Morus.Presentation
{
    public class PresenterDiscoveryResult
    {
        private readonly IEnumerable<IView> _viewInstances;
        private readonly string _message;
        private readonly IEnumerable<PresenterBinding> _bindings;

        [DebuggerStepThrough]
        public PresenterDiscoveryResult(IEnumerable<IView> viewInstances, string message, IEnumerable<PresenterBinding> bindings)
        {
            _viewInstances = viewInstances;
            _message = message;
            _bindings = bindings;
        }

        public IEnumerable<IView> ViewInstances
        {
            [DebuggerStepThrough]
            get
            {
                return _viewInstances;
            }
        }

        public string Message
        {
            [DebuggerStepThrough]
            get
            {
                return _message;
            }
        }

        public IEnumerable<PresenterBinding> Bindings
        {
            [DebuggerStepThrough]
            get
            {
                return _bindings;
            }
        }

        public override bool Equals(object obj)
        {
            var target = obj as PresenterDiscoveryResult;
            if (target == null)
            {
                return false;
            }

            return
                ViewInstances.SetEqual(target.ViewInstances) &&
                Message.Equals(target.Message, StringComparison.OrdinalIgnoreCase) &&
                Bindings.SetEqual(target.Bindings);
        }

        public override int GetHashCode()
        {
            return
                ViewInstances.GetHashCode() |
                Message.GetHashCode() |
                Bindings.GetHashCode();
        }
    }
}
